local yiji = fk.CreateSkill {

  name = "joyex__yiji",

  tags = {  },

}



yiji:addEffect(fk.Damaged, {
  name = "joyex__yiji",
  anim_type = "masochism",
  events = {fk.Damaged},
  on_trigger = function(self, event, target, player, data)
    self.cancel_cost = false
    for _ = 1, data.damage do
      if player.dead or self.cancel_cost then return end
      self:doCost(event, target, player, data)
    end
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askForSkillInvoke(target, yiji.name, data) then return true end
    self.cancel_cost = true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(2, yiji.name)
    if player.dead or player:isKongcheng() then return end
    player.room:askForYiji (player, player:getCardIds("h"), room:getOtherPlayers(player), yiji.name, 0, 2)
  end
})

return yiji